<!-- HTML header for doxygen 1.8.8-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <!-- For Mobile Devices -->
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
        <meta name="generator" content="Doxygen 1.8.17"/>
        <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
        <title>QuEST: Decoherence</title>
        <!--<link href="tabs.css" rel="stylesheet" type="text/css"/>-->
        <script type="text/javascript" src="dynsections.js"></script>
        <link href="doxygen.css" rel="stylesheet" type="text/css" />
        <link href="style.css" rel="stylesheet" type="text/css"/>
        <link href='https://fonts.googleapis.com/css?family=Roboto+Slab' rel='stylesheet' type='text/css'>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
        <link href="jquery.smartmenus.bootstrap.css" rel="stylesheet">
        <script type="text/javascript" src="jquery.smartmenus.js"></script>
        <!-- SmartMenus jQuery Bootstrap Addon -->
        <script type="text/javascript" src="jquery.smartmenus.bootstrap.js"></script>
        <!-- SmartMenus jQuery plugin -->
    </head>
    <body>
        <nav class="navbar navbar-default" role="navigation">
            <div class="container">
                <div class="navbar-header">
                    <a class="navbar-brand"><img alt="Logo" src="logo.png"/></a>
                    <a class="navbar-brand"><b>QuEST</b> v3.2.0<br>The Quantum Exact Simulation Toolkit</a>
                </div>
            </div>
        </nav>
        <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
            <div class="content" id="content">
                <div class="container">
                    <div class="row">
                        <div class="col-sm-12 panel " style="padding-bottom: 15px;">
                            <div style="margin-bottom: 15px;">
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Decoherence</div>  </div>
</div><!--header-->
<div class="contents">

<p>Decoherence channels which act on density matrices to induce mixing.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gaea8509011985522bae857bd3b13c34ed"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__decoherence.html#gaea8509011985522bae857bd3b13c34ed">mixDamping</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> prob)</td></tr>
<tr class="memdesc:gaea8509011985522bae857bd3b13c34ed"><td class="mdescLeft">&#160;</td><td class="mdescRight">Mixes a density matrix <code>qureg</code> to induce single-qubit amplitude damping (decay to 0 state).  <a href="group__decoherence.html#gaea8509011985522bae857bd3b13c34ed">More...</a><br /></td></tr>
<tr class="separator:gaea8509011985522bae857bd3b13c34ed"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga97d563fa8f4bc51f720bbb653f5480b3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__decoherence.html#ga97d563fa8f4bc51f720bbb653f5480b3">mixDensityMatrix</a> (<a class="el" href="structQureg.html">Qureg</a> combineQureg, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> prob, <a class="el" href="structQureg.html">Qureg</a> otherQureg)</td></tr>
<tr class="memdesc:ga97d563fa8f4bc51f720bbb653f5480b3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies combineQureg to become (1-prob)combineProb + prob otherQureg.  <a href="group__decoherence.html#ga97d563fa8f4bc51f720bbb653f5480b3">More...</a><br /></td></tr>
<tr class="separator:ga97d563fa8f4bc51f720bbb653f5480b3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gacc2667ac87482a7afdcb711b74bf732e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__decoherence.html#gacc2667ac87482a7afdcb711b74bf732e">mixDephasing</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> prob)</td></tr>
<tr class="memdesc:gacc2667ac87482a7afdcb711b74bf732e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Mixes a density matrix <code>qureg</code> to induce single-qubit dephasing noise.  <a href="group__decoherence.html#gacc2667ac87482a7afdcb711b74bf732e">More...</a><br /></td></tr>
<tr class="separator:gacc2667ac87482a7afdcb711b74bf732e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae2ea9255b8b11a4a382231e5604dc4e3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__decoherence.html#gae2ea9255b8b11a4a382231e5604dc4e3">mixDepolarising</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> prob)</td></tr>
<tr class="memdesc:gae2ea9255b8b11a4a382231e5604dc4e3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Mixes a density matrix <code>qureg</code> to induce single-qubit homogeneous depolarising noise.  <a href="group__decoherence.html#gae2ea9255b8b11a4a382231e5604dc4e3">More...</a><br /></td></tr>
<tr class="separator:gae2ea9255b8b11a4a382231e5604dc4e3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gacb7faa9d8afb0f4270c866424fffbccd"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__decoherence.html#gacb7faa9d8afb0f4270c866424fffbccd">mixKrausMap</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int target, <a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> *ops, int numOps)</td></tr>
<tr class="memdesc:gacb7faa9d8afb0f4270c866424fffbccd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Apply a general single-qubit Kraus map to a density matrix, as specified by at most four Kraus operators, <img class="formulaInl" alt="$K_i$" src="form_156.png"/> (<code>ops</code>).  <a href="group__decoherence.html#gacb7faa9d8afb0f4270c866424fffbccd">More...</a><br /></td></tr>
<tr class="separator:gacb7faa9d8afb0f4270c866424fffbccd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga65b4c0944090fae78a37ba3b94811ace"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__decoherence.html#ga65b4c0944090fae78a37ba3b94811ace">mixMultiQubitKrausMap</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *targets, int numTargets, <a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a> *ops, int numOps)</td></tr>
<tr class="memdesc:ga65b4c0944090fae78a37ba3b94811ace"><td class="mdescLeft">&#160;</td><td class="mdescRight">Apply a general N-qubit Kraus map to a density matrix, as specified by at most (2N)^2 Kraus operators.  <a href="group__decoherence.html#ga65b4c0944090fae78a37ba3b94811ace">More...</a><br /></td></tr>
<tr class="separator:ga65b4c0944090fae78a37ba3b94811ace"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9a77f84e1aa7d25d036b14d7d0cd8b61"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__decoherence.html#ga9a77f84e1aa7d25d036b14d7d0cd8b61">mixPauli</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> probX, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> probY, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> probZ)</td></tr>
<tr class="memdesc:ga9a77f84e1aa7d25d036b14d7d0cd8b61"><td class="mdescLeft">&#160;</td><td class="mdescRight">Mixes a density matrix <code>qureg</code> to induce general single-qubit Pauli noise.  <a href="group__decoherence.html#ga9a77f84e1aa7d25d036b14d7d0cd8b61">More...</a><br /></td></tr>
<tr class="separator:ga9a77f84e1aa7d25d036b14d7d0cd8b61"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga14282bdb1dc65760ca9ecbe6305eb770"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__decoherence.html#ga14282bdb1dc65760ca9ecbe6305eb770">mixTwoQubitDephasing</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int qubit1, int qubit2, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> prob)</td></tr>
<tr class="memdesc:ga14282bdb1dc65760ca9ecbe6305eb770"><td class="mdescLeft">&#160;</td><td class="mdescRight">Mixes a density matrix <code>qureg</code> to induce two-qubit dephasing noise.  <a href="group__decoherence.html#ga14282bdb1dc65760ca9ecbe6305eb770">More...</a><br /></td></tr>
<tr class="separator:ga14282bdb1dc65760ca9ecbe6305eb770"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gacfc45a8fc86ee18f60866bbd0c874ed0"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__decoherence.html#gacfc45a8fc86ee18f60866bbd0c874ed0">mixTwoQubitDepolarising</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int qubit1, int qubit2, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> prob)</td></tr>
<tr class="memdesc:gacfc45a8fc86ee18f60866bbd0c874ed0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Mixes a density matrix <code>qureg</code> to induce two-qubit homogeneous depolarising noise.  <a href="group__decoherence.html#gacfc45a8fc86ee18f60866bbd0c874ed0">More...</a><br /></td></tr>
<tr class="separator:gacfc45a8fc86ee18f60866bbd0c874ed0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga2cf7dece0efea4207349f872cdcb7e81"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__decoherence.html#ga2cf7dece0efea4207349f872cdcb7e81">mixTwoQubitKrausMap</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int target1, int target2, <a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a> *ops, int numOps)</td></tr>
<tr class="memdesc:ga2cf7dece0efea4207349f872cdcb7e81"><td class="mdescLeft">&#160;</td><td class="mdescRight">Apply a general two-qubit Kraus map to a density matrix, as specified by at most sixteen Kraus operators.  <a href="group__decoherence.html#ga2cf7dece0efea4207349f872cdcb7e81">More...</a><br /></td></tr>
<tr class="separator:ga2cf7dece0efea4207349f872cdcb7e81"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Decoherence channels which act on density matrices to induce mixing. </p>
<h2 class="groupheader">Function Documentation</h2>
<a id="gaea8509011985522bae857bd3b13c34ed"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaea8509011985522bae857bd3b13c34ed">&#9670;&nbsp;</a></span>mixDamping()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mixDamping </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>prob</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Mixes a density matrix <code>qureg</code> to induce single-qubit amplitude damping (decay to 0 state). </p>
<p>With probability <code>prob</code>, applies damping (transition from 1 to 0 state).</p>
<p>This transforms <code>qureg</code> = <img class="formulaInl" alt="$\rho$" src="form_95.png"/> into the mixed state </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ K_0 \rho K_0^\dagger + K_1 \rho K_1^\dagger \]" src="form_101.png"/>
</p>
<p> where q = <code>targetQubit</code> and <img class="formulaInl" alt="$K_0$" src="form_102.png"/> and <img class="formulaInl" alt="$K_1$" src="form_103.png"/> are Kraus operators </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ K_0 = \begin{pmatrix} 1 &amp; 0 \\ 0 &amp; \sqrt{1-\text{prob}} \end{pmatrix}, \;\; K_1 = \begin{pmatrix} 0 &amp; \sqrt{\text{prob}} \\ 0 &amp; 0 \end{pmatrix}. \]" src="form_104.png"/>
</p>
<p> <code>prob</code> cannot exceed 1, at which total damping/decay occurs. Note that unlike <a class="el" href="group__decoherence.html#gacc2667ac87482a7afdcb711b74bf732e" title="Mixes a density matrix qureg to induce single-qubit dephasing noise.">mixDephasing()</a> and <a class="el" href="group__decoherence.html#gae2ea9255b8b11a4a382231e5604dc4e3" title="Mixes a density matrix qureg to induce single-qubit homogeneous depolarising noise.">mixDepolarising()</a>, this function can increase the purity of a mixed state (by, as <code>prob</code> becomes 1, gaining certainty that the qubit is in the 0 state).</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>a density matrix </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">targetQubit</td><td>qubit upon which to induce amplitude damping </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">prob</td><td>the probability of the damping </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if <code>qureg</code> is not a density matrix, or if <code>targetQubit</code> is outside [0, <code>qureg.numQubitsRepresented</code>), or if <code>prob</code> is not in [0, 1] </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Nicolas Vogt of HQS (local CPU) </dd>
<dd>
Ania Brown (GPU, patched local CPU) </dd>
<dd>
Tyson Jones (distributed, doc) </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01034">1034</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01034"></a><span class="lineno"> 1034</span>&#160;                                                          {</div>
<div class="line"><a name="l01035"></a><span class="lineno"> 1035</span>&#160;    <a class="code" href="QuEST__validation_8c.html#af22919f5190ca1b3b6b52b8f2fb8213b">validateDensityMatrQureg</a>(qureg, __func__);</div>
<div class="line"><a name="l01036"></a><span class="lineno"> 1036</span>&#160;    <a class="code" href="QuEST__validation_8c.html#ac31c45c5a31c523be0eb26abba6cf598">validateTarget</a>(qureg, targetQubit, __func__);</div>
<div class="line"><a name="l01037"></a><span class="lineno"> 1037</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a260639d187d09cbeef3ff36f0d4d1f0e">validateOneQubitDampingProb</a>(prob, __func__);</div>
<div class="line"><a name="l01038"></a><span class="lineno"> 1038</span>&#160;    </div>
<div class="line"><a name="l01039"></a><span class="lineno"> 1039</span>&#160;    <a class="code" href="QuEST__internal_8h.html#ac501fe7b9d331be48359ce1546348f97">densmatr_mixDamping</a>(qureg, targetQubit, prob);</div>
<div class="line"><a name="l01040"></a><span class="lineno"> 1040</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00725">densmatr_mixDamping()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00483">validateDensityMatrQureg()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00542">validateOneQubitDampingProb()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00364">validateTarget()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__decoherence_8cpp_source.html#l00023">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga97d563fa8f4bc51f720bbb653f5480b3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga97d563fa8f4bc51f720bbb653f5480b3">&#9670;&nbsp;</a></span>mixDensityMatrix()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mixDensityMatrix </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>combineQureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>prob</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>otherQureg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies combineQureg to become (1-prob)combineProb + prob otherQureg. </p>
<p>Both registers must be equal-dimension density matrices, and prob must be in [0, 1].</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">combineQureg</td><td>a density matrix to be modified </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">prob</td><td>the probability of <code>otherQureg</code> in the modified <code>combineQureg</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">otherQureg</td><td>a density matrix to be mixed into <code>combineQureg</code> </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if either <code>combineQureg</code> or <code>otherQureg</code> are not density matrices, or if the dimensions of <code>combineQureg</code> and <code>otherQureg</code> do not match, or if <code>prob</code> is not in [0, 1] </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00772">772</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00772"></a><span class="lineno">  772</span>&#160;                                                                             {</div>
<div class="line"><a name="l00773"></a><span class="lineno">  773</span>&#160;    <a class="code" href="QuEST__validation_8c.html#af22919f5190ca1b3b6b52b8f2fb8213b">validateDensityMatrQureg</a>(combineQureg, __func__);</div>
<div class="line"><a name="l00774"></a><span class="lineno">  774</span>&#160;    <a class="code" href="QuEST__validation_8c.html#af22919f5190ca1b3b6b52b8f2fb8213b">validateDensityMatrQureg</a>(otherQureg, __func__);</div>
<div class="line"><a name="l00775"></a><span class="lineno">  775</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a87d22240ccfd81827a2a34b8d569d347">validateMatchingQuregDims</a>(combineQureg, otherQureg, __func__);</div>
<div class="line"><a name="l00776"></a><span class="lineno">  776</span>&#160;    <a class="code" href="QuEST__validation_8c.html#ae06b0f6b669c03241d0db3b9dc560da1">validateProb</a>(otherProb, __func__);</div>
<div class="line"><a name="l00777"></a><span class="lineno">  777</span>&#160;    </div>
<div class="line"><a name="l00778"></a><span class="lineno">  778</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a8adaba9dbdad6f7ab41ae4b8db0abefe">densmatr_mixDensityMatrix</a>(combineQureg, otherProb, otherQureg);</div>
<div class="line"><a name="l00779"></a><span class="lineno">  779</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l00890">densmatr_mixDensityMatrix()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00483">validateDensityMatrQureg()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00495">validateMatchingQuregDims()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00515">validateProb()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__decoherence_8cpp_source.html#l00073">TEST_CASE()</a>.</p>

</div>
</div>
<a id="gacc2667ac87482a7afdcb711b74bf732e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gacc2667ac87482a7afdcb711b74bf732e">&#9670;&nbsp;</a></span>mixDephasing()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mixDephasing </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>prob</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Mixes a density matrix <code>qureg</code> to induce single-qubit dephasing noise. </p>
<p>With probability <code>prob</code>, applies Pauli Z to <code>targetQubit</code>.</p>
<p>This transforms <code>qureg</code> = <img class="formulaInl" alt="$\rho$" src="form_95.png"/> into the mixed state </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ (1 - \text{prob}) \, \rho + \text{prob} \; Z_q \, \rho \, Z_q \]" src="form_96.png"/>
</p>
<p> where q = <code>targetQubit</code>. <code>prob</code> cannot exceed 1/2, which maximally mixes <code>targetQubit</code>.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>a density matrix </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">targetQubit</td><td>qubit upon which to induce dephasing noise </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">prob</td><td>the probability of the phase error occuring </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if <code>qureg</code> is not a density matrix, or if <code>targetQubit</code> is outside [0, <code>qureg.numQubitsRepresented</code>), or if <code>prob</code> is not in [0, 1/2] </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones (GPU, doc) </dd>
<dd>
Ania Brown (CPU, distributed) </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01001">1001</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01001"></a><span class="lineno"> 1001</span>&#160;                                                            {</div>
<div class="line"><a name="l01002"></a><span class="lineno"> 1002</span>&#160;    <a class="code" href="QuEST__validation_8c.html#af22919f5190ca1b3b6b52b8f2fb8213b">validateDensityMatrQureg</a>(qureg, __func__);</div>
<div class="line"><a name="l01003"></a><span class="lineno"> 1003</span>&#160;    <a class="code" href="QuEST__validation_8c.html#ac31c45c5a31c523be0eb26abba6cf598">validateTarget</a>(qureg, targetQubit, __func__);</div>
<div class="line"><a name="l01004"></a><span class="lineno"> 1004</span>&#160;    <a class="code" href="QuEST__validation_8c.html#aef4d89ae4b8a8b4f414ebd03ef4c6acf">validateOneQubitDephaseProb</a>(prob, __func__);</div>
<div class="line"><a name="l01005"></a><span class="lineno"> 1005</span>&#160;    </div>
<div class="line"><a name="l01006"></a><span class="lineno"> 1006</span>&#160;    <a class="code" href="QuEST__internal_8h.html#aa31f0ef43a921c3ac73545d1d3670fa1">densmatr_mixDephasing</a>(qureg, targetQubit, 2*prob);</div>
<div class="line"><a name="l01007"></a><span class="lineno"> 1007</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, </div>
<div class="line"><a name="l01008"></a><span class="lineno"> 1008</span>&#160;        <span class="stringliteral">&quot;Here, a phase (Z) error occured on qubit %d with probability %g&quot;</span>, targetQubit, prob);</div>
<div class="line"><a name="l01009"></a><span class="lineno"> 1009</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l00079">densmatr_mixDephasing()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00120">qasm_recordComment()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00483">validateDensityMatrQureg()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00527">validateOneQubitDephaseProb()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00364">validateTarget()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__decoherence_8cpp_source.html#l00134">TEST_CASE()</a>.</p>

</div>
</div>
<a id="gae2ea9255b8b11a4a382231e5604dc4e3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae2ea9255b8b11a4a382231e5604dc4e3">&#9670;&nbsp;</a></span>mixDepolarising()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mixDepolarising </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>prob</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Mixes a density matrix <code>qureg</code> to induce single-qubit homogeneous depolarising noise. </p>
<p>This is equivalent to, with probability <code>prob</code>, uniformly randomly applying either Pauli X, Y, or Z to <code>targetQubit</code>.</p>
<p>This transforms <code>qureg</code> = <img class="formulaInl" alt="$\rho$" src="form_95.png"/> into the mixed state </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ (1 - \text{prob}) \, \rho + \frac{\text{prob}}{3} \; \left( X_q \, \rho \, X_q + Y_q \, \rho \, Y_q + Z_q \, \rho \, Z_q \right) \]" src="form_98.png"/>
</p>
<p> where q = <code>targetQubit</code>. <code>prob</code> cannot exceed 3/4, at which maximal mixing occurs. The produced state is equivalently expressed as </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \left( 1 - \frac{4}{3} \text{prob} \right) \rho + \left( \frac{4}{3} \text{prob} \right) \frac{\vec{\bf{1}}}{2} \]" src="form_99.png"/>
</p>
<p> where <img class="formulaInl" alt="$ \frac{\vec{\bf{1}}}{2} $" src="form_100.png"/> is the maximally mixed state of the target qubit.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>a density matrix </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">targetQubit</td><td>qubit upon which to induce depolarising noise </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">prob</td><td>the probability of the depolarising error occuring </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if <code>qureg</code> is not a density matrix, or if <code>targetQubit</code> is outside [0, <code>qureg.numQubitsRepresented</code>), or if <code>prob</code> is not in [0, 3/4] </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones (GPU, doc) </dd>
<dd>
Ania Brown (CPU, distributed) </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01023">1023</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01023"></a><span class="lineno"> 1023</span>&#160;                                                               {</div>
<div class="line"><a name="l01024"></a><span class="lineno"> 1024</span>&#160;    <a class="code" href="QuEST__validation_8c.html#af22919f5190ca1b3b6b52b8f2fb8213b">validateDensityMatrQureg</a>(qureg, __func__);</div>
<div class="line"><a name="l01025"></a><span class="lineno"> 1025</span>&#160;    <a class="code" href="QuEST__validation_8c.html#ac31c45c5a31c523be0eb26abba6cf598">validateTarget</a>(qureg, targetQubit, __func__);</div>
<div class="line"><a name="l01026"></a><span class="lineno"> 1026</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a269b2f7ee5c4376ae633cd2b77a7be38">validateOneQubitDepolProb</a>(prob, __func__);</div>
<div class="line"><a name="l01027"></a><span class="lineno"> 1027</span>&#160;    </div>
<div class="line"><a name="l01028"></a><span class="lineno"> 1028</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a398b60c4cb4fa2cf2ffc126de6c08da0">densmatr_mixDepolarising</a>(qureg, targetQubit, (4*prob)/3.0);</div>
<div class="line"><a name="l01029"></a><span class="lineno"> 1029</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg,</div>
<div class="line"><a name="l01030"></a><span class="lineno"> 1030</span>&#160;        <span class="stringliteral">&quot;Here, a homogeneous depolarising error (X, Y, or Z) occured on &quot;</span></div>
<div class="line"><a name="l01031"></a><span class="lineno"> 1031</span>&#160;        <span class="stringliteral">&quot;qubit %d with total probability %g&quot;</span>, targetQubit, prob);</div>
<div class="line"><a name="l01032"></a><span class="lineno"> 1032</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00698">densmatr_mixDepolarising()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00120">qasm_recordComment()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00483">validateDensityMatrQureg()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00537">validateOneQubitDepolProb()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00364">validateTarget()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__decoherence_8cpp_source.html#l00180">TEST_CASE()</a>.</p>

</div>
</div>
<a id="gacb7faa9d8afb0f4270c866424fffbccd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gacb7faa9d8afb0f4270c866424fffbccd">&#9670;&nbsp;</a></span>mixKrausMap()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mixKrausMap </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>target</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> *&#160;</td>
          <td class="paramname"><em>ops</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numOps</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Apply a general single-qubit Kraus map to a density matrix, as specified by at most four Kraus operators, <img class="formulaInl" alt="$K_i$" src="form_156.png"/> (<code>ops</code>). </p>
<p>A Kraus map is also referred to as a "operator-sum representation" of a quantum channel, and enables the simulation of general single-qubit noise process, by effecting </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \rho \to \sum\limits_i^{\text{numOps}} K_i \rho K_i^\dagger \]" src="form_157.png"/>
</p>
<p>The Kraus map must be completely positive and trace preserving, which constrains each <img class="formulaInl" alt="$ K_i $" src="form_158.png"/> in <code>ops</code> by </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \sum \limits_i^{\text{numOps}} K_i^\dagger K_i = I \]" src="form_159.png"/>
</p>
<p> where <img class="formulaInl" alt="$ I $" src="form_160.png"/> is the identity matrix.</p>
<p>Note that in distributed mode, this routine requires that each node contains at least 4 amplitudes. This means an q-qubit register can be distributed by at most 2^(q-2) numTargs nodes.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>the density matrix to which to apply the map </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">target</td><td>the target qubit of the map </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">ops</td><td>an array of at most 4 Kraus operators </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numOps</td><td>the number of operators in <code>ops</code> which must be &gt;0 and &lt;= 4. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if <code>qureg</code> is not a density matrix, or if <code>target</code> is outside of [0, <code>qureg.numQubitsRepresented</code>), or if <code>numOps</code> is outside [1, 4], or if <code>ops</code> do not create a completely positive, trace preserving map, or if a node cannot fit 4 amplitudes in distributed mode. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Balint Koczor </dd>
<dd>
Tyson Jones (refactored, doc) </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01065">1065</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01065"></a><span class="lineno"> 1065</span>&#160;                                                                           {</div>
<div class="line"><a name="l01066"></a><span class="lineno"> 1066</span>&#160;    <a class="code" href="QuEST__validation_8c.html#af22919f5190ca1b3b6b52b8f2fb8213b">validateDensityMatrQureg</a>(qureg, __func__);</div>
<div class="line"><a name="l01067"></a><span class="lineno"> 1067</span>&#160;    <a class="code" href="QuEST__validation_8c.html#ac31c45c5a31c523be0eb26abba6cf598">validateTarget</a>(qureg, target, __func__);</div>
<div class="line"><a name="l01068"></a><span class="lineno"> 1068</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a2d43dbc8bf59a58b0ba9da31a8b7db8b">validateOneQubitKrausMap</a>(qureg, ops, numOps, __func__);</div>
<div class="line"><a name="l01069"></a><span class="lineno"> 1069</span>&#160;    </div>
<div class="line"><a name="l01070"></a><span class="lineno"> 1070</span>&#160;    <a class="code" href="QuEST__common_8c.html#ab987904f721746d1176aba7ac6b566fa">densmatr_mixKrausMap</a>(qureg, target, ops, numOps);</div>
<div class="line"><a name="l01071"></a><span class="lineno"> 1071</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, </div>
<div class="line"><a name="l01072"></a><span class="lineno"> 1072</span>&#160;        <span class="stringliteral">&quot;Here, an undisclosed Kraus map was effected on qubit %d&quot;</span>, target);</div>
<div class="line"><a name="l01073"></a><span class="lineno"> 1073</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00600">densmatr_mixKrausMap()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00120">qasm_recordComment()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00483">validateDensityMatrQureg()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00574">validateOneQubitKrausMap()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00364">validateTarget()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__decoherence_8cpp_source.html#l00520">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga65b4c0944090fae78a37ba3b94811ace"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga65b4c0944090fae78a37ba3b94811ace">&#9670;&nbsp;</a></span>mixMultiQubitKrausMap()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mixMultiQubitKrausMap </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>targets</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTargets</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a> *&#160;</td>
          <td class="paramname"><em>ops</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numOps</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Apply a general N-qubit Kraus map to a density matrix, as specified by at most (2N)^2 Kraus operators. </p>
<p>This allows one to simulate a general noise process.</p>
<p>The Kraus map must be completely positive and trace preserving, which constrains each <img class="formulaInl" alt="$ K_i $" src="form_158.png"/> in <code>ops</code> by </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \sum \limits_i^{\text{numOps}} K_i^\dagger K_i = I \]" src="form_159.png"/>
</p>
<p> where <img class="formulaInl" alt="$ I $" src="form_160.png"/> is the identity matrix.</p>
<p>The first qubit in <code>targets</code> is treated as the <code>least</code> significant qubit in each op in <code>ops</code>.</p>
<p>Note that in distributed mode, this routine requires that each node contains at least (2N)^2 amplitudes. This means an q-qubit register can be distributed by at most 2^(q-2)/N^2 nodes.</p>
<p>Note too that this routine internally creates a 'superoperator'; a complex matrix of dimensions 2^(2*numTargets) by 2^(2*numTargets). Therefore, invoking this function incurs, for numTargs={1,2,3,4,5, ...}, an additional memory overhead of (at double-precision) {0.25 KiB, 4 KiB, 64 KiB, 1 MiB, 16 MiB, ...} (respectively). At quad precision (usually 10 B per number, but possibly 16 B due to alignment), this costs at most double the amount of memory. For numTargets &lt; 4, this superoperator will be created in the runtime stack. For numTargs &gt;= 4, the superoperator will be allocated in the heap and therefore this routine may suffer an anomalous slowdown.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>the density matrix to which to apply the map </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">targets</td><td>a list of target qubit indices, the first of which is treated as least significant in each op in <code>ops</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numTargets</td><td>the length of <code>targets</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">ops</td><td>an array of at most (2N)^2 Kraus operators </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numOps</td><td>the number of operators in <code>ops</code> which must be &gt;0 and &lt;= (2N)^2. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if <code>qureg</code> is not a density matrix, or if any target in <code>targets</code> is outside of [0, <code>qureg.numQubitsRepresented</code>), or if any qubit in <code>targets</code> is repeated, or if <code>numOps</code> is outside [1, (2 <code>numTargets</code>)^2], or if any <a class="el" href="structComplexMatrixN.html" title="Represents a general 2^N by 2^N matrix of complex numbers.">ComplexMatrixN</a> in \ops does not have op.numQubits == <code>numTargets</code>, or if <code>ops</code> do not create a completely positive, trace preserving map, or if a node cannot fit (2N)^2 amplitudes in distributed mode. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd>
<dd>
Balint Koczor </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01085">1085</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01085"></a><span class="lineno"> 1085</span>&#160;                                                                                                       {</div>
<div class="line"><a name="l01086"></a><span class="lineno"> 1086</span>&#160;    <a class="code" href="QuEST__validation_8c.html#af22919f5190ca1b3b6b52b8f2fb8213b">validateDensityMatrQureg</a>(qureg, __func__);</div>
<div class="line"><a name="l01087"></a><span class="lineno"> 1087</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a6776217a5f7ba38b56175cf6db0f96e0">validateMultiTargets</a>(qureg, targets, numTargets, __func__);</div>
<div class="line"><a name="l01088"></a><span class="lineno"> 1088</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a38738db33da795b9d52bace2d9fbe7ee">validateMultiQubitKrausMap</a>(qureg, numTargets, ops, numOps, __func__);</div>
<div class="line"><a name="l01089"></a><span class="lineno"> 1089</span>&#160;    </div>
<div class="line"><a name="l01090"></a><span class="lineno"> 1090</span>&#160;    <a class="code" href="QuEST__common_8c.html#a99702f4667c429969d7e7b4ecd45c2f3">densmatr_mixMultiQubitKrausMap</a>(qureg, targets, numTargets, ops, numOps);</div>
<div class="line"><a name="l01091"></a><span class="lineno"> 1091</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg,</div>
<div class="line"><a name="l01092"></a><span class="lineno"> 1092</span>&#160;        <span class="stringliteral">&quot;Here, an undisclosed %d-qubit Kraus map was applied to undisclosed qubits&quot;</span>, numTargets);</div>
<div class="line"><a name="l01093"></a><span class="lineno"> 1093</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00643">densmatr_mixMultiQubitKrausMap()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00120">qasm_recordComment()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00483">validateDensityMatrQureg()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00598">validateMultiQubitKrausMap()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00392">validateMultiTargets()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__decoherence_8cpp_source.html#l00229">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga9a77f84e1aa7d25d036b14d7d0cd8b61"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga9a77f84e1aa7d25d036b14d7d0cd8b61">&#9670;&nbsp;</a></span>mixPauli()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mixPauli </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>probX</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>probY</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>probZ</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Mixes a density matrix <code>qureg</code> to induce general single-qubit Pauli noise. </p>
<p>With probabilities <code>probX</code>, <code>probY</code> and <code>probZ</code>, applies Pauli X, Y, and Z respectively to <code>targetQubit</code>.</p>
<p>This transforms <code>qureg</code> = <img class="formulaInl" alt="$\rho$" src="form_95.png"/> into the mixed state </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ (1 - \text{probX} - \text{probY} - \text{probZ}) \, \rho + \;\;\; (\text{probX})\; X_q \, \rho \, X_q + \;\;\; (\text{probY})\; Y_q \, \rho \, Y_q + \;\;\; (\text{probZ})\; Z_q \, \rho \, Z_q \]" src="form_110.png"/>
</p>
<p> where q = <code>targetQubit</code>. Each of <code>probX</code>, <code>probY</code> and <code>probZ</code> cannot exceed the chance of no error: 1 - <code>probX</code> - <code>probY</code> - <code>probZ</code> </p>
<p>This function operates by first converting the given Pauli probabilities into a single-qubit Kraus map (four 2x2 operators).</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>a density matrix </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">targetQubit</td><td>qubit to decohere </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">probX</td><td>the probability of inducing an X error </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">probX</td><td>the probability of inducing an Y error </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">probX</td><td>the probability of inducing an Z error </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if <code>qureg</code> is not a density matrix, or if <code>targetQubit</code> is outside [0, <code>qureg.numQubitsRepresented</code>), or if any of <code>probX</code>, <code>probY</code> or <code>probZ</code> are not in [0, 1], or if any of p in {<code>probX</code>, <code>probY</code> or <code>probZ}</code> don't satisfy p &lt;= (1 - <code>probX</code> - <code>probY</code> - <code>probZ</code>) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Balint Koczor </dd>
<dd>
Tyson Jones (refactored, doc) </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01054">1054</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01054"></a><span class="lineno"> 1054</span>&#160;                                                                             {</div>
<div class="line"><a name="l01055"></a><span class="lineno"> 1055</span>&#160;    <a class="code" href="QuEST__validation_8c.html#af22919f5190ca1b3b6b52b8f2fb8213b">validateDensityMatrQureg</a>(qureg, __func__);</div>
<div class="line"><a name="l01056"></a><span class="lineno"> 1056</span>&#160;    <a class="code" href="QuEST__validation_8c.html#ac31c45c5a31c523be0eb26abba6cf598">validateTarget</a>(qureg, qubit, __func__);</div>
<div class="line"><a name="l01057"></a><span class="lineno"> 1057</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a1b018a5766c1b26c731e8dcaa76abb19">validateOneQubitPauliProbs</a>(probX, probY, probZ, __func__);</div>
<div class="line"><a name="l01058"></a><span class="lineno"> 1058</span>&#160;    </div>
<div class="line"><a name="l01059"></a><span class="lineno"> 1059</span>&#160;    <a class="code" href="QuEST__common_8c.html#a63bf6575f12d7113fb854a2b6cc1a756">densmatr_mixPauli</a>(qureg, qubit, probX, probY, probZ);</div>
<div class="line"><a name="l01060"></a><span class="lineno"> 1060</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg,</div>
<div class="line"><a name="l01061"></a><span class="lineno"> 1061</span>&#160;        <span class="stringliteral">&quot;Here, X, Y and Z errors occured on qubit %d with probabilities &quot;</span></div>
<div class="line"><a name="l01062"></a><span class="lineno"> 1062</span>&#160;        <span class="stringliteral">&quot;%g, %g and %g respectively&quot;</span>, qubit, probX, probY, probZ);</div>
<div class="line"><a name="l01063"></a><span class="lineno"> 1063</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00676">densmatr_mixPauli()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00120">qasm_recordComment()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00483">validateDensityMatrQureg()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00552">validateOneQubitPauliProbs()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00364">validateTarget()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__decoherence_8cpp_source.html#l00442">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga14282bdb1dc65760ca9ecbe6305eb770"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga14282bdb1dc65760ca9ecbe6305eb770">&#9670;&nbsp;</a></span>mixTwoQubitDephasing()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mixTwoQubitDephasing </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qubit1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qubit2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>prob</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Mixes a density matrix <code>qureg</code> to induce two-qubit dephasing noise. </p>
<p>With probability <code>prob</code>, applies Pauli Z to either or both qubits.</p>
<p>This transforms <code>qureg</code> = <img class="formulaInl" alt="$\rho$" src="form_95.png"/> into the mixed state </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ (1 - \text{prob}) \, \rho + \frac{\text{prob}}{3} \; \left( Z_a \, \rho \, Z_a + Z_b \, \rho \, Z_b + Z_a Z_b \, \rho \, Z_a Z_b \right) \]" src="form_97.png"/>
</p>
<p> where a = <code>qubit1</code>, b = <code>qubit2</code>. <code>prob</code> cannot exceed 3/4, at which maximal mixing occurs.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>a density matrix </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">qubit1</td><td>qubit upon which to induce dephasing noise </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">qubit2</td><td>qubit upon which to induce dephasing noise </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">prob</td><td>the probability of the phase error occuring </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if <code>qureg</code> is not a density matrix, or if either <code>qubit1</code> or <code>qubit2</code> is outside [0, <code>qureg.numQubitsRepresented</code>), or if <code>qubit1</code> = <code>qubit2</code>, or if <code>prob</code> is not in [0, 3/4] </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones (GPU, doc) </dd>
<dd>
Ania Brown (CPU, distributed) </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01011">1011</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01011"></a><span class="lineno"> 1011</span>&#160;                                                                           {</div>
<div class="line"><a name="l01012"></a><span class="lineno"> 1012</span>&#160;    <a class="code" href="QuEST__validation_8c.html#af22919f5190ca1b3b6b52b8f2fb8213b">validateDensityMatrQureg</a>(qureg, __func__);</div>
<div class="line"><a name="l01013"></a><span class="lineno"> 1013</span>&#160;    <a class="code" href="QuEST__validation_8c.html#aed5f85789dc4fa43b64e99e6b538035c">validateUniqueTargets</a>(qureg, qubit1, qubit2, __func__);</div>
<div class="line"><a name="l01014"></a><span class="lineno"> 1014</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a2f58e35b04edfbc053e0c9ae19f1be97">validateTwoQubitDephaseProb</a>(prob, __func__);</div>
<div class="line"><a name="l01015"></a><span class="lineno"> 1015</span>&#160; </div>
<div class="line"><a name="l01016"></a><span class="lineno"> 1016</span>&#160;    <a class="code" href="QuEST__common_8c.html#ac8ea84dd85eca525daeeb30b3c96b673">ensureIndsIncrease</a>(&amp;qubit1, &amp;qubit2);</div>
<div class="line"><a name="l01017"></a><span class="lineno"> 1017</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a623e577b7230f3c8dc202be6185b4289">densmatr_mixTwoQubitDephasing</a>(qureg, qubit1, qubit2, (4*prob)/3.0);</div>
<div class="line"><a name="l01018"></a><span class="lineno"> 1018</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg,</div>
<div class="line"><a name="l01019"></a><span class="lineno"> 1019</span>&#160;        <span class="stringliteral">&quot;Here, a phase (Z) error occured on either or both of qubits &quot;</span></div>
<div class="line"><a name="l01020"></a><span class="lineno"> 1020</span>&#160;        <span class="stringliteral">&quot;%d and %d with total probability %g&quot;</span>, qubit1, qubit2, prob);</div>
<div class="line"><a name="l01021"></a><span class="lineno"> 1021</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l00084">densmatr_mixTwoQubitDephasing()</a>, <a class="el" href="QuEST__common_8c_source.html#l00064">ensureIndsIncrease()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00120">qasm_recordComment()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00483">validateDensityMatrQureg()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00532">validateTwoQubitDephaseProb()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00378">validateUniqueTargets()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__decoherence_8cpp_source.html#l00594">TEST_CASE()</a>.</p>

</div>
</div>
<a id="gacfc45a8fc86ee18f60866bbd0c874ed0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gacfc45a8fc86ee18f60866bbd0c874ed0">&#9670;&nbsp;</a></span>mixTwoQubitDepolarising()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mixTwoQubitDepolarising </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qubit1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qubit2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>prob</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Mixes a density matrix <code>qureg</code> to induce two-qubit homogeneous depolarising noise. </p>
<p>With probability <code>prob</code>, applies to <code>qubit1</code> and <code>qubit2</code> any operator of the set <img class="formulaInl" alt="$\{ IX, IY, IZ, XI, YI, ZI, XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ \}$" src="form_105.png"/>. Note this is the set of all two-qubit Pauli gates excluding <img class="formulaInl" alt="$II$" src="form_106.png"/>.</p>
<p>This transforms <code>qureg</code> = <img class="formulaInl" alt="$\rho$" src="form_95.png"/> into the mixed state </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ (1 - \text{prob}) \, \rho \; + \; \frac{\text{prob}}{15} \; \left( \sum \limits_{\sigma_a \in \{X_a,Y_a,Z_a,I_a\}} \sum \limits_{\sigma_b \in \{X_b,Y_b,Z_b,I_b\}} \sigma_a \sigma_b \; \rho \; \sigma_a \sigma_b \right) - \frac{\text{prob}}{15} I_a I_b \; \rho \; I_a I_b \]" src="form_107.png"/>
</p>
<p> or verbosely </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ (1 - \text{prob}) \, \rho + \frac{\text{prob}}{15} \; \left( \begin{aligned} &amp;X_a \, \rho \, X_a + X_b \, \rho \, X_b + Y_a \, \rho \, Y_a + Y_b \, \rho \, Y_b + Z_a \, \rho \, Z_a + Z_b \, \rho \, Z_b \\ + &amp;X_a X_b \, \rho \, X_a X_b + X_a Y_b \, \rho \, X_a Y_b + X_a Z_b \, \rho \, X_a Z_b + Y_a X_b \, \rho \, Y_a X_b \\ + &amp;Y_a Y_b \, \rho \, Y_a Y_b + Y_a Z_b \, \rho \, Y_a Z_b + Z_a X_b \, \rho \, Z_a X_b + Z_a Y_b \, \rho \, Z_a Y_b + Z_a Z_b \, \rho \, Z_a Z_b \end{aligned} \right) \]" src="form_108.png"/>
</p>
<p> where a = <code>qubit1</code>, b = <code>qubit2</code>.</p>
<p><code>prob</code> cannot exceed 15/16, at which maximal mixing occurs.</p>
<p>The produced state is equivalently expressed as </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \left( 1 - \frac{16}{15} \text{prob} \right) \rho + \left( \frac{16}{15} \text{prob} \right) \frac{\vec{\bf{1}}}{2} \]" src="form_109.png"/>
</p>
<p> where <img class="formulaInl" alt="$ \frac{\vec{\bf{1}}}{2} $" src="form_100.png"/> is the maximally mixed state of the two target qubits.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>a density matrix </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">qubit1</td><td>qubit upon which to induce depolarising noise </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">qubit2</td><td>qubit upon which to induce depolarising noise </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">prob</td><td>the probability of the depolarising error occuring </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if <code>qureg</code> is not a density matrix, or if either <code>qubit1</code> or <code>qubit2</code> is outside [0, <code>qureg.numQubitsRepresented</code>), or if <code>qubit1</code> = <code>qubit2</code>, or if <code>prob</code> is not in [0, 15/16] </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones (GPU, doc) </dd>
<dd>
Ania Brown (CPU, distributed) </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01042">1042</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01042"></a><span class="lineno"> 1042</span>&#160;                                                                              {</div>
<div class="line"><a name="l01043"></a><span class="lineno"> 1043</span>&#160;    <a class="code" href="QuEST__validation_8c.html#af22919f5190ca1b3b6b52b8f2fb8213b">validateDensityMatrQureg</a>(qureg, __func__);</div>
<div class="line"><a name="l01044"></a><span class="lineno"> 1044</span>&#160;    <a class="code" href="QuEST__validation_8c.html#aed5f85789dc4fa43b64e99e6b538035c">validateUniqueTargets</a>(qureg, qubit1, qubit2, __func__);</div>
<div class="line"><a name="l01045"></a><span class="lineno"> 1045</span>&#160;    <a class="code" href="QuEST__validation_8c.html#abedaf81fa9ed252b2f8fbd1bd73f8f8e">validateTwoQubitDepolProb</a>(prob, __func__);</div>
<div class="line"><a name="l01046"></a><span class="lineno"> 1046</span>&#160;    </div>
<div class="line"><a name="l01047"></a><span class="lineno"> 1047</span>&#160;    <a class="code" href="QuEST__common_8c.html#ac8ea84dd85eca525daeeb30b3c96b673">ensureIndsIncrease</a>(&amp;qubit1, &amp;qubit2);</div>
<div class="line"><a name="l01048"></a><span class="lineno"> 1048</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a43afa97e300b87bce7f3eb1213eb05f6">densmatr_mixTwoQubitDepolarising</a>(qureg, qubit1, qubit2, (16*prob)/15.0);</div>
<div class="line"><a name="l01049"></a><span class="lineno"> 1049</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg,</div>
<div class="line"><a name="l01050"></a><span class="lineno"> 1050</span>&#160;        <span class="stringliteral">&quot;Here, a homogeneous depolarising error occured on qubits %d and %d &quot;</span></div>
<div class="line"><a name="l01051"></a><span class="lineno"> 1051</span>&#160;        <span class="stringliteral">&quot;with total probability %g&quot;</span>, qubit1, qubit2, prob);</div>
<div class="line"><a name="l01052"></a><span class="lineno"> 1052</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00752">densmatr_mixTwoQubitDepolarising()</a>, <a class="el" href="QuEST__common_8c_source.html#l00064">ensureIndsIncrease()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00120">qasm_recordComment()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00483">validateDensityMatrQureg()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00547">validateTwoQubitDepolProb()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00378">validateUniqueTargets()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__decoherence_8cpp_source.html#l00653">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga2cf7dece0efea4207349f872cdcb7e81"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga2cf7dece0efea4207349f872cdcb7e81">&#9670;&nbsp;</a></span>mixTwoQubitKrausMap()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mixTwoQubitKrausMap </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>target1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>target2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a> *&#160;</td>
          <td class="paramname"><em>ops</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numOps</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Apply a general two-qubit Kraus map to a density matrix, as specified by at most sixteen Kraus operators. </p>
<p>A Kraus map is also referred to as a "operator-sum representation" of a quantum channel. This allows one to simulate a general two-qubit noise process.</p>
<p>The Kraus map must be completely positive and trace preserving, which constrains each <img class="formulaInl" alt="$ K_i $" src="form_158.png"/> in <code>ops</code> by </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \sum \limits_i^{\text{numOps}} K_i^\dagger K_i = I \]" src="form_159.png"/>
</p>
<p> where <img class="formulaInl" alt="$ I $" src="form_160.png"/> is the identity matrix.</p>
<p><code>targetQubit1</code> is treated as the <code>least</code> significant qubit in each op in <code>ops</code>.</p>
<p>Note that in distributed mode, this routine requires that each node contains at least 16 amplitudes. This means an q-qubit register can be distributed by at most 2^(q-4) numTargs nodes.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>the density matrix to which to apply the map </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">target1</td><td>the least significant target qubit in <code>ops</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">target2</td><td>the most significant target qubit in <code>ops</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">ops</td><td>an array of at most 16 Kraus operators </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numOps</td><td>the number of operators in <code>ops</code> which must be &gt;0 and &lt;= 16. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if <code>qureg</code> is not a density matrix, or if either <code>target1</code> or <code>target2</code> is outside of [0, <code>qureg.numQubitsRepresented</code>), or if <code>target1</code> = <code>target2</code>, or if <code>numOps</code> is outside [1, 16], or if <code>ops</code> do not create a completely positive, trace preserving map, or if a node cannot fit 16 amplitudes in distributed mode. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Balint Koczor </dd>
<dd>
Tyson Jones (refactored, doc) </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01075">1075</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01075"></a><span class="lineno"> 1075</span>&#160;                                                                                                 {</div>
<div class="line"><a name="l01076"></a><span class="lineno"> 1076</span>&#160;    <a class="code" href="QuEST__validation_8c.html#af22919f5190ca1b3b6b52b8f2fb8213b">validateDensityMatrQureg</a>(qureg, __func__);</div>
<div class="line"><a name="l01077"></a><span class="lineno"> 1077</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a6776217a5f7ba38b56175cf6db0f96e0">validateMultiTargets</a>(qureg, (<span class="keywordtype">int</span>[]) {target1,target2}, 2, __func__);</div>
<div class="line"><a name="l01078"></a><span class="lineno"> 1078</span>&#160;    <a class="code" href="QuEST__validation_8c.html#ad0f5b8fe9cf31ef3a565e722966a5511">validateTwoQubitKrausMap</a>(qureg, ops, numOps, __func__);</div>
<div class="line"><a name="l01079"></a><span class="lineno"> 1079</span>&#160;    </div>
<div class="line"><a name="l01080"></a><span class="lineno"> 1080</span>&#160;    <a class="code" href="QuEST__common_8c.html#ab004038b5f906ea897621c88bf213129">densmatr_mixTwoQubitKrausMap</a>(qureg, target1, target2, ops, numOps);</div>
<div class="line"><a name="l01081"></a><span class="lineno"> 1081</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, </div>
<div class="line"><a name="l01082"></a><span class="lineno"> 1082</span>&#160;        <span class="stringliteral">&quot;Here, an undisclosed two-qubit Kraus map was effected on qubits %d and %d&quot;</span>, target1, target2);</div>
<div class="line"><a name="l01083"></a><span class="lineno"> 1083</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00635">densmatr_mixTwoQubitKrausMap()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00120">qasm_recordComment()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00483">validateDensityMatrQureg()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00392">validateMultiTargets()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00586">validateTwoQubitKrausMap()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__decoherence_8cpp_source.html#l00720">TEST_CASE()</a>.</p>

</div>
</div>
</div><!-- contents -->
<div class="ttc" id="aQuEST__internal_8h_html_a398b60c4cb4fa2cf2ffc126de6c08da0"><div class="ttname"><a href="QuEST__internal_8h.html#a398b60c4cb4fa2cf2ffc126de6c08da0">densmatr_mixDepolarising</a></div><div class="ttdeci">void densmatr_mixDepolarising(Qureg qureg, int targetQubit, qreal depolLevel)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00698">QuEST_cpu_distributed.c:698</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_af22919f5190ca1b3b6b52b8f2fb8213b"><div class="ttname"><a href="QuEST__validation_8c.html#af22919f5190ca1b3b6b52b8f2fb8213b">validateDensityMatrQureg</a></div><div class="ttdeci">void validateDensityMatrQureg(Qureg qureg, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00483">QuEST_validation.c:483</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_ac31c45c5a31c523be0eb26abba6cf598"><div class="ttname"><a href="QuEST__validation_8c.html#ac31c45c5a31c523be0eb26abba6cf598">validateTarget</a></div><div class="ttdeci">void validateTarget(Qureg qureg, int targetQubit, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00364">QuEST_validation.c:364</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_ab987904f721746d1176aba7ac6b566fa"><div class="ttname"><a href="QuEST__common_8c.html#ab987904f721746d1176aba7ac6b566fa">densmatr_mixKrausMap</a></div><div class="ttdeci">void densmatr_mixKrausMap(Qureg qureg, int target, ComplexMatrix2 *ops, int numOps)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00600">QuEST_common.c:600</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_ae06b0f6b669c03241d0db3b9dc560da1"><div class="ttname"><a href="QuEST__validation_8c.html#ae06b0f6b669c03241d0db3b9dc560da1">validateProb</a></div><div class="ttdeci">void validateProb(qreal prob, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00515">QuEST_validation.c:515</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a99702f4667c429969d7e7b4ecd45c2f3"><div class="ttname"><a href="QuEST__common_8c.html#a99702f4667c429969d7e7b4ecd45c2f3">densmatr_mixMultiQubitKrausMap</a></div><div class="ttdeci">void densmatr_mixMultiQubitKrausMap(Qureg qureg, int *targets, int numTargets, ComplexMatrixN *ops, int numOps)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00643">QuEST_common.c:643</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_abedaf81fa9ed252b2f8fbd1bd73f8f8e"><div class="ttname"><a href="QuEST__validation_8c.html#abedaf81fa9ed252b2f8fbd1bd73f8f8e">validateTwoQubitDepolProb</a></div><div class="ttdeci">void validateTwoQubitDepolProb(qreal prob, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00547">QuEST_validation.c:547</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a8adaba9dbdad6f7ab41ae4b8db0abefe"><div class="ttname"><a href="QuEST__internal_8h.html#a8adaba9dbdad6f7ab41ae4b8db0abefe">densmatr_mixDensityMatrix</a></div><div class="ttdeci">void densmatr_mixDensityMatrix(Qureg combineQureg, qreal otherProb, Qureg otherQureg)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00890">QuEST_cpu.c:890</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_aa31f0ef43a921c3ac73545d1d3670fa1"><div class="ttname"><a href="QuEST__internal_8h.html#aa31f0ef43a921c3ac73545d1d3670fa1">densmatr_mixDephasing</a></div><div class="ttdeci">void densmatr_mixDephasing(Qureg qureg, int targetQubit, qreal dephase)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00079">QuEST_cpu.c:79</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_aef4d89ae4b8a8b4f414ebd03ef4c6acf"><div class="ttname"><a href="QuEST__validation_8c.html#aef4d89ae4b8a8b4f414ebd03ef4c6acf">validateOneQubitDephaseProb</a></div><div class="ttdeci">void validateOneQubitDephaseProb(qreal prob, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00527">QuEST_validation.c:527</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a6776217a5f7ba38b56175cf6db0f96e0"><div class="ttname"><a href="QuEST__validation_8c.html#a6776217a5f7ba38b56175cf6db0f96e0">validateMultiTargets</a></div><div class="ttdeci">void validateMultiTargets(Qureg qureg, int *targetQubits, int numTargetQubits, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00392">QuEST_validation.c:392</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a623e577b7230f3c8dc202be6185b4289"><div class="ttname"><a href="QuEST__internal_8h.html#a623e577b7230f3c8dc202be6185b4289">densmatr_mixTwoQubitDephasing</a></div><div class="ttdeci">void densmatr_mixTwoQubitDephasing(Qureg qureg, int qubit1, int qubit2, qreal dephase)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00084">QuEST_cpu.c:84</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a87d22240ccfd81827a2a34b8d569d347"><div class="ttname"><a href="QuEST__validation_8c.html#a87d22240ccfd81827a2a34b8d569d347">validateMatchingQuregDims</a></div><div class="ttdeci">void validateMatchingQuregDims(Qureg qureg1, Qureg qureg2, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00495">QuEST_validation.c:495</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_ab004038b5f906ea897621c88bf213129"><div class="ttname"><a href="QuEST__common_8c.html#ab004038b5f906ea897621c88bf213129">densmatr_mixTwoQubitKrausMap</a></div><div class="ttdeci">void densmatr_mixTwoQubitKrausMap(Qureg qureg, int target1, int target2, ComplexMatrix4 *ops, int numOps)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00635">QuEST_common.c:635</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_ac501fe7b9d331be48359ce1546348f97"><div class="ttname"><a href="QuEST__internal_8h.html#ac501fe7b9d331be48359ce1546348f97">densmatr_mixDamping</a></div><div class="ttdeci">void densmatr_mixDamping(Qureg qureg, int targetQubit, qreal damping)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00725">QuEST_cpu_distributed.c:725</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a2d43dbc8bf59a58b0ba9da31a8b7db8b"><div class="ttname"><a href="QuEST__validation_8c.html#a2d43dbc8bf59a58b0ba9da31a8b7db8b">validateOneQubitKrausMap</a></div><div class="ttdeci">void validateOneQubitKrausMap(Qureg qureg, ComplexMatrix2 *ops, int numOps, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00574">QuEST_validation.c:574</a></div></div>
<div class="ttc" id="aQuEST__qasm_8c_html_a9a385fde708958617bbeb599064b8dcb"><div class="ttname"><a href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a></div><div class="ttdeci">void qasm_recordComment(Qureg qureg, char *comment,...)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__qasm_8c_source.html#l00120">QuEST_qasm.c:120</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a43afa97e300b87bce7f3eb1213eb05f6"><div class="ttname"><a href="QuEST__internal_8h.html#a43afa97e300b87bce7f3eb1213eb05f6">densmatr_mixTwoQubitDepolarising</a></div><div class="ttdeci">void densmatr_mixTwoQubitDepolarising(Qureg qureg, int qubit1, int qubit2, qreal depolLevel)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00752">QuEST_cpu_distributed.c:752</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a269b2f7ee5c4376ae633cd2b77a7be38"><div class="ttname"><a href="QuEST__validation_8c.html#a269b2f7ee5c4376ae633cd2b77a7be38">validateOneQubitDepolProb</a></div><div class="ttdeci">void validateOneQubitDepolProb(qreal prob, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00537">QuEST_validation.c:537</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_ad0f5b8fe9cf31ef3a565e722966a5511"><div class="ttname"><a href="QuEST__validation_8c.html#ad0f5b8fe9cf31ef3a565e722966a5511">validateTwoQubitKrausMap</a></div><div class="ttdeci">void validateTwoQubitKrausMap(Qureg qureg, ComplexMatrix4 *ops, int numOps, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00586">QuEST_validation.c:586</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a63bf6575f12d7113fb854a2b6cc1a756"><div class="ttname"><a href="QuEST__common_8c.html#a63bf6575f12d7113fb854a2b6cc1a756">densmatr_mixPauli</a></div><div class="ttdeci">void densmatr_mixPauli(Qureg qureg, int qubit, qreal probX, qreal probY, qreal probZ)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00676">QuEST_common.c:676</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a38738db33da795b9d52bace2d9fbe7ee"><div class="ttname"><a href="QuEST__validation_8c.html#a38738db33da795b9d52bace2d9fbe7ee">validateMultiQubitKrausMap</a></div><div class="ttdeci">void validateMultiQubitKrausMap(Qureg qureg, int numTargs, ComplexMatrixN *ops, int numOps, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00598">QuEST_validation.c:598</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_ac8ea84dd85eca525daeeb30b3c96b673"><div class="ttname"><a href="QuEST__common_8c.html#ac8ea84dd85eca525daeeb30b3c96b673">ensureIndsIncrease</a></div><div class="ttdeci">void ensureIndsIncrease(int *ind1, int *ind2)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00064">QuEST_common.c:64</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a260639d187d09cbeef3ff36f0d4d1f0e"><div class="ttname"><a href="QuEST__validation_8c.html#a260639d187d09cbeef3ff36f0d4d1f0e">validateOneQubitDampingProb</a></div><div class="ttdeci">void validateOneQubitDampingProb(qreal prob, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00542">QuEST_validation.c:542</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_aed5f85789dc4fa43b64e99e6b538035c"><div class="ttname"><a href="QuEST__validation_8c.html#aed5f85789dc4fa43b64e99e6b538035c">validateUniqueTargets</a></div><div class="ttdeci">void validateUniqueTargets(Qureg qureg, int qubit1, int qubit2, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00378">QuEST_validation.c:378</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a2f58e35b04edfbc053e0c9ae19f1be97"><div class="ttname"><a href="QuEST__validation_8c.html#a2f58e35b04edfbc053e0c9ae19f1be97">validateTwoQubitDephaseProb</a></div><div class="ttdeci">void validateTwoQubitDephaseProb(qreal prob, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00532">QuEST_validation.c:532</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a1b018a5766c1b26c731e8dcaa76abb19"><div class="ttname"><a href="QuEST__validation_8c.html#a1b018a5766c1b26c731e8dcaa76abb19">validateOneQubitPauliProbs</a></div><div class="ttdeci">void validateOneQubitPauliProbs(qreal probX, qreal probY, qreal probZ, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00552">QuEST_validation.c:552</a></div></div>
<!-- HTML footer for doxygen 1.8.8-->
<!-- start footer part -->
</div>
</div>
</div>
</div>
</div>
</body>
        <script type="text/javascript" src="boot.js"></script>
</html>
